<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <style>
        .tim {
            width: 200px;
            height: 200px;
            border: 12px solid #7e97ca;
            border-radius: 116px;
            background-color: #ffd4fc;
            position: fixed;
            right: 50%;
            bottom: 50%;
            transform: translate(50%, 50%);
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
        }
    </style>
    <body>
        <div class="tim"></div>
        <script>
            function getTime() {
                let html = document.querySelector(".tim");
                var time = new Date();
                // 获取年
                var year = time.getFullYear();
                // 获取月份
                var month = time.getMonth();
                // 获取日
                var day = time.getDate();
                // 获取星期几
                var week = time.getDay();
                var arrayWeek = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
                // 获取时
                var hours = time.getHours() >= 10 ? time.getHours() : "0" + time.getHours();
                // 获取时分
                var minutes = time.getMinutes() >= 10 ? time.getMinutes() : "0" + time.getMinutes();
                // 获取秒
                let seconds = time.getSeconds() >= 10 ? time.getSeconds() : "0" + time.getSeconds();
                html.innerHTML =
                    year +
                    "年" +
                    (month + 1) +
                    "月" +
                    day +
                    "日" +
                    "</br>" +
                    arrayWeek[week] +
                    "</br>" +
                    hours +
                    ":" +
                    minutes +
                    ":" +
                    seconds;
            }

            setInterval(() => {
                getTime();
            }, 1000);
        </script>
        <script>
            // 批量化制造数据
            function arraySet() {
                const arr = [];
                for (let i = 0; i < 10; i++) {
                    arr.push({
                        name: `name${i + 1}`
                    });
                }
                return arr;
            }
            // const data = arraySet();

            /* ------------- */
            function createData() {
                // 如果不 fill 循环默认会跳过空值
                const oldArr = new Array(10).fill(null);
                const newArr = oldArr.map((v, i) => ({ name: `name2${i + 1}` }));
                console.log(newArr);
                console.log(oldArr);
                return oldArr;
            }
            // const data2 = createData();

            /* ------------ */
            let arr = [12, 45, 97, 9797, 564, 134, 45642];
            let set = new Set(arr);
            // console.log(set); //返回的是一个类数组
            const array = Array.from(set); //使用Array.from()方法将类数组转换为真正的数组
            // console.log(array);

            /* ------数组的合并于去重----- */
            const arr1 = [1, 2, 3, 4];
            const arr2 = [3, 4, 5, 6, 7];
            // console.log([...arr1, ...arr2]); //合并
            // console.log(new Set([...arr1, ...arr2])); //去重
            // console.log(Array.from(new Set([...arr1, ...arr2]))); //类数组转数组

            const arr3 = arr1.slice(0);
            arr1.slice(2);
            console.log(arr1);
            console.log(arr3);
        </script>
    </body>
</html>
